#include <stdio.h>
#include <string.h>
#include <iostream.h>

char card[88][5];
char in[5];
int n,num;

int choose[5];

void checkout()
{
	int i ;
	for (i=0; i<4; ++i)
		if ( (card[choose[1]][i]==card[choose[2]][i] && card[choose[3]][i]==card[choose[2]][i] )
			|| (card[choose[1]][i]!=card[choose[2]][i] && card[choose[1]][i]!=card[choose[3]][i] && card[choose[2]][i]!=card[choose[3]][i] ))
			;
		else	return ;
	++num;
	if (num==1) printf("SETS:   1.  %s %s %s\n",card[choose[1]],card[choose[2]],card[choose[3]]);
	else        printf("        %d.  %s %s %s\n",num, card[choose[1]],card[choose[2]],card[choose[3]]);

}

void search(int pt)
{
	int i;
	if (pt>3)
	{
		checkout();
	}
	else
	{
		for (i=choose[pt-1]+1; i<=n; i++)
		{
			choose[pt]=i;
			search(pt+1);
		}

	}

}

void doit()
{
	int i;
	printf("CARDS:  %s", card[1]);
	for (i=2; i<=n; ++i) printf(" %s",card[i]);
	printf("\n");

	choose[0]=0;
	num=0;
	search(1);

	if (num==0) printf("SETS:   *** None Found ***\n");
	printf("\n");			

	n=0;
	memset(card,0,sizeof(card));
}

int main()
{
	n = 0;
	
//	freopen("1053.out", "w", stdout);
//	freopen("1053.in", "r", stdin);
	while (scanf("%c", &in[0])!=EOF)
	{
		if (in[0]!='\n')
		{
			gets(in+1);
			strcpy(card[++n], in);
		}
		else
			doit();
	}// end of while 
	if (n!=0)
		doit();

	return 0;
}